const express = require("express");
const getSendData = require("../utils/getSendData");
const demoServ = require("../services/demoService");

const router = express.Router();

router.get("/", async (req, res, next) => {
    res.send(getSendData(await demoServ.getDemos()));
});

router.post("/", async (req, res, next) => {
    res.send(getSendData([await demoServ.addDemo(req.body)]));
});

router.put("/:id", async (req, res, next) => {
    res.send(getSendData([await demoServ.updateDemo(req.params.id, req.body)]));
});

router.delete("/:id", async (req, res, next) => {
    res.send(getSendData(await demoServ.deleteDemo(req.params.id)));
});

module.exports = router;
